import request from '@/router/axios';
import { baseUrl } from '@/config/env';

export const getMenuTree= () => request({
  url: baseUrl + '/menu/tree',
  method: 'get'
})

export const submitMenu = (data) => {
  return request({
    url: baseUrl + '/menu/submit',
    method: 'post',
    data: data
  })
}

export const removeMenu = (ids) => {
  return request({
    url: baseUrl + '/menu/remove',
    method: 'post',
    params: {
      ids,
    }
  })
}

export const getMenu = (id) => {
  return request({
    url: baseUrl + '/menu/detail',
    method: 'get',
    params: {
      id,
    }
  })
}

export const getRoleList = (current, size, params) => {
  return request({
    url: baseUrl+'/role/pagelist',
    method: 'get',
    params: {
      ...params,
      current,
      size,
    }
  })
}
export const getRoleMenu = (roleIds) => {
  return request({
    url: baseUrl+'/menu/role-menu-keys',
    method: 'get',
    params: {
      roleIds,
    }
  })
}
export const submitRole = (row) => {
  return request({
    url: baseUrl+'/role/submit',
    method: 'post',
    data: row
  })
}
export const removeRole = (ids) => {
  return request({
    url: baseUrl+'/role/remove',
    method: 'post',
    params: {
      ids,
    }
  })
}
export const updateRoleMenu = (roleIds, menuIds) => {
  return request({
    url: baseUrl+'/role/role-menu',
    method: 'post',
    params: {
      roleIds,
      menuIds
    }
  })
}
export const getDeptList = (current, size, params) => {
  return request({
    url: baseUrl + '/dept/list',
    method: 'get',
    params: {
      ...params,
      current,
      size,
    }
  })
}

export const submitDept = (row) => {
  return request({
    url: baseUrl+'/dept/submit',
    method: 'post',
    data: row
  })
}
export const removeDept = (ids) => {
  return request({
    url: baseUrl+'/dept/remove',
    method: 'post',
    params: {
      ids,
    }
  })
}
export const getDept = (id) => {
  return request({
    url: baseUrl+'/dept/detail',
    method: 'get',
    params: {
      id,
    }
  })
}
export const getDeptTree = () => {
  return request({
    url: baseUrl+'/dept/tree',
    method: 'get',

  })
}

export const addUser = (row) => {
  return request({
    url: baseUrl+'/user/add-user',
    method: 'post',
    data: row
  })
}
export const getUserMenu = () => {
  return request({
    url: baseUrl+'/user/menu',
    method: 'get',
  })
}

